<template>
    <div class="alltable">
        <table border="0" cellspacing="1" cellpadding="0">
            <tr>
                <th>数据名称</th>
                <td colspan="1">{{data.analyzeName}}</td>
                <th>下载大小</th>
                <td colspan="1">{{getFileSize(data.downloadTotalSize)}}</td>
                <th>分析文件数</th>
                <td colspan="1">{{data.analyzeFinished + '/' + data.analyzeTotal}}</td>
            </tr>
            <tr>
                <th>首页地址</th>
                <td colspan="1">{{data.homeUrl}}</td>
                <th>创建时间</th>
                <td colspan="3">{{data.createTime}}</td>
            </tr>
            <tr>
                <th>状态</th>
                <td colspan="1"><span :class="data.toStateObj.key"></span>{{data.toStateObj.value}}</td>
                <th>分享进度</th>
                <td colspan="3"><el-progress :percentage="data.progress"></el-progress></td>
            </tr>
            <tr>
                <th>上次启动时间</th>
                <td colspan="1">{{data.lastStartTimeStr||'未启动'}}</td>
                <th>分析用时</th>
                <td colspan="1">{{getTime(data.analyzeCostTime)}}</td>
                <th>过滤数量</th>
                <td colspan="1">{{data.analyzeFiltered+data.analyzeFailed}}</td>
            </tr>
        </table>
    </div>
</template>

<script>
    export default {
        name: "allTable",
        props:['data'],
        data(){
            return{

            }
        },
        methods:{
            getTime(time){
              let lastTime='0秒';
              if(time===1000) lastTime='1秒';
              else if(time>1000 &&time<60000) lastTime=(time / 1000).toFixed(1)+'秒';
              else if(time===60000) lastTime='1分钟';
              else if(time>60000&&time<3600000) lastTime=(time / 60000).toFixed(1)+'分钟';
              else if(time===3600000) lastTime='1小时';
              else if(time>3600000)lastTime=(time / 3600000).toFixed(1)+'小时';
              return lastTime
            },
            getFileSize(fileByte) {
                var fileSizeByte = fileByte;
                var fileSizeMsg = '0KB';
                if (fileSizeByte < 1048576) fileSizeMsg = (fileSizeByte / 1024).toFixed(1) + "KB";
                else if (fileSizeByte == 1048576) fileSizeMsg = "1MB";
                else if (fileSizeByte > 1048576 && fileSizeByte < 1073741824) fileSizeMsg = (fileSizeByte / (1024 * 1024)).toFixed(1) + "MB";
                else if (fileSizeByte > 1048576 && fileSizeByte == 1073741824) fileSizeMsg = "1GB";
                else if (fileSizeByte > 1073741824 && fileSizeByte < 1099511627776) fileSizeMsg = (fileSizeByte / (1024 * 1024 * 1024)).toFixed(1) + "GB";
                else if (fileSizeByte > 1099511627775)fileSizeMsg = (fileSizeByte / (1024 * 1024 * 1024*1024)).toFixed(1) + "TB";
                return fileSizeMsg;
            },
        }
    }
</script>

<style scoped lang="scss">
    .alltable {
        table {
            width: 100%;
            background: #e8e8e8;
            td {
                background: #fff;
                padding: 16px 24px;
                text-align: left;
                color: rgba(0, 0, 0, 0.65);
                font-size: 14px;
                span{
                    display: inline-block;
                    height: 6px;
                    width: 6px;
                    background: #d9d9d9;
                    border-radius: 50%;
                    vertical-align: middle;
                    margin-right: 10px;
                    margin-top: -2px;
                }
                .processing{
                    background: #1890ff;
                }
                .success {
                    background-color: #52c41a;
                }
                .error {
                    background-color: #f5222d;
                }
            }
            th{
                background: #fafafa;
                padding: 16px 24px;
                text-align: left;
                color: rgba(0, 0, 0, 0.85);
                font-weight: normal;
                font-size: 14px;
                line-height: 1.5;
            }
        }
    }
</style>